//
//  DetailHeaderView.m
//  BTRIP
//
//  Created by johnbk on 15/11/17.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "DetailHeaderView.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
@implementation DetailHeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame
{
	self = [super initWithFrame:frame];
	if (self) {
		[self createView];
	}
	return self;
}
- (void)createView{
	self.imageViewOfBackground = [[UIImageView alloc]init];
	[self addSubview:self.imageViewOfBackground];
	[self.imageViewOfBackground release];
	self.labelOfName = [[UILabel alloc]init];
	[self addSubview:self.labelOfName];
	[self.labelOfName release];
	self.labelOfDash = [[UILabel alloc]init];
	[self addSubview:self.labelOfDash];
	[self.labelOfDash release];
	self.labelOfTitle = [[UILabel alloc]init];
	[self addSubview:self.labelOfTitle];
	[self.labelOfTitle release];
}
- (void)layoutSubviews{
	[super layoutSubviews];
	self.imageViewOfBackground.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
	self.labelOfName.frame = CGRectMake(0, 0, self.frame.size.width, 40);
	self.labelOfName.textColor = [UIColor whiteColor];
	self.labelOfName.font = [UIFont systemFontOfSize:18];
	self.labelOfName.center = CGPointMake(self.frame.size.width / 2, self.frame.size.height - 100);
	self.labelOfName.textAlignment = NSTextAlignmentCenter;
	self.labelOfDash.frame = CGRectMake(self.labelOfName.frame.origin.x, self.labelOfName.frame.origin.y + self.labelOfName.frame.size.height, self.labelOfName.frame.size.width, 40);
	self.labelOfDash.text = @"————————— —————————";
	self.labelOfDash.textColor = [UIColor whiteColor];
	self.labelOfTitle.textColor = [UIColor whiteColor];
	self.labelOfTitle.frame = CGRectMake(self.labelOfDash.frame.origin.x, self.labelOfDash.frame.origin.y + self.labelOfDash.frame.size.height, self.labelOfName.frame.size.width, 30);
	self.labelOfTitle.font = [UIFont systemFontOfSize:14];
	self.labelOfTitle.textAlignment = NSTextAlignmentCenter;
	self.labelOfDash.textAlignment = NSTextAlignmentCenter;
}
- (void)setDetailSpecialModel:(DetailSpecialModel *)detailSpecialModel{
	if (_detailSpecialModel != detailSpecialModel) {
		[_detailSpecialModel release];
		_detailSpecialModel = [detailSpecialModel retain];
		[self.imageViewOfBackground sd_setImageWithURL:[NSURL URLWithString:detailSpecialModel.image_url] placeholderImage:[UIImage imageNamed:@"background"]];
		self.labelOfName.text = detailSpecialModel.name;
		self.labelOfTitle.text = detailSpecialModel.title;
	}
}
@end
